package com.zmn.plat.services.impl.channel.product.map;

import com.zmn.common.dto.StatusDTO;
import com.zmn.plat.model.entity.channel.product.map.ChannelProductMap;
import com.zmn.plat.model.entity.channel.product.map.ChannelProductMapQuery;
import com.zmn.plat.persistence.interfaces.channel.product.map.ChannelProductMapDao;
import com.zmn.plat.services.interfaces.channel.product.map.ChannelProductMapService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * 渠道产品映射service实现类
 *
 * @author linfeng
 *
 * @since 2020/10/28 11:07
 */
@Service
public class ChannelProductMapServiceImpl implements ChannelProductMapService {

    @Resource
    ChannelProductMapDao channelProductMapDao;

    @Override
    public ChannelProductMap findByKey(Integer relateId) {
        return channelProductMapDao.findByKey(relateId);
    }

    @Override
    public List<ChannelProductMap> listPageByQuery(ChannelProductMapQuery query) {
        int count = countByQuery(query);
        query.setTotalCount(count);
        return channelProductMapDao.listPageByQuery(query);
    }

    @Override
    public List<ChannelProductMap> listByQuery(ChannelProductMapQuery query) {
        return channelProductMapDao.listByQuery(query);
    }

    @Override
    public List<ChannelProductMap> listAll() {
        return channelProductMapDao.listAll();
    }

    @Override
    public Integer countByQuery(ChannelProductMapQuery query) {
        return channelProductMapDao.countByQuery(query);
    }

    @Override
    public Integer updateByKey(ChannelProductMap channelProductMap) {
        return channelProductMapDao.updateByKey(channelProductMap);
    }

    @Override
    public Integer updateStatus(ChannelProductMap channelProductMap) {
        return channelProductMapDao.updateStatus(channelProductMap);
    }

    @Override
    public Integer updateStatusBatch(StatusDTO dto) {
        return channelProductMapDao.updateStatusBatch(dto);
    }

    @Override
    public Integer insert(ChannelProductMap channelProductMap) {
        return channelProductMapDao.insert(channelProductMap);
    }

    @Override
    public Integer insertBatch(List<ChannelProductMap> channelProductMapList) {
        return channelProductMapDao.insertBatch(channelProductMapList);
    }

    @Override
    public Integer deleteByKey(Integer relateId) {
        return channelProductMapDao.deleteByKey(relateId);
    }

    @Override
    public Integer deleteByChannelId(Integer channelId) {
        return channelProductMapDao.deleteByChannelId(channelId);
    }

    @Override
    public Integer deleteByChannelIdAndProductId(Integer channelId, Integer productId, Integer channelProductParentId) {
        return channelProductMapDao.deleteByChannelIdAndProductId(channelId, productId, channelProductParentId);
    }

    @Override
    public void copy(Integer originalChannelId, int targetChannelId, String operator) {

        channelProductMapDao.copy(originalChannelId, targetChannelId, operator);
    }
}